/**
  * Created by wyc on 6/11/2017.
  */
package ninenineqs

object p04 {
  def length_v1[T](input:List[T]):Int = {
    input.length
  }
  def length_v2[T](input:List[T]):Int = {
    input match {
      case Nil => 0
      case _ :: tail => 1 + length_v2(tail)
    }
  }
  def length_v3[T](input:List[T]):Int = {
    input.foldLeft(0){(c,_) => c + 1}
  }
}
